﻿using System;

namespace SimulationCenter.Models
{
    public class Resp
    {
        public bool IsSuccess { get; set; }

        public int? Code { get; set; }

        public string Msg { get; set; }

        public Exception Exception { get; set; }

        public object Data { get; set; }

        public static Resp Success(object data = default, int? code = null, string msg = null)
        {
            return new Resp()
            {
                IsSuccess = true,
                Code = code,
                Msg = msg,
                Data = data
            };
        }

        public static Resp Failure(string msg = null, int? code = null, object data = default)
        {
            return new Resp()
            {
                IsSuccess = false,
                Code = code,
                Msg = msg,
                Data = data
            };
        }

        public static Resp Failure(Exception e)
        {
            return new Resp()
            {
                IsSuccess = false,
                Exception = e
            };
        }
    }
}
